import 'package:aio/aio.dart';
import 'package:flutter/material.dart';
import 'package:app/src/http/url.dart';

// "FileList": [{
// "FileId": "1130",
// "FileName": "厂房全景接片.jpg",
// "FilePatch": "http://test.bwg2017.com/UploadFile/CutFile/20211102178804/厂房全景接片.jpg",
// "StatusDescription": "新增"
// }],

///附件
class Attachment extends BaseBean {
  String? FileId = "";

  //文件名
  String? FileName = "";

  //下载地址
  String? FilePatch = "";

  //状态描述
  String? StatusDescription = "";

  @override
  fromJson(Map<String, dynamic> json) {
    // TODO: implement fromJson
    FileId = json['FileId']?.toString() ?? "";
    FileName = json['FileName']?.toString() ?? "";
    FilePatch = json['FilePatch']?.toString() ?? "";
    StatusDescription = json['StatusDescription']?.toString() ?? "";
    // json?.forEach((key, value) {
    //   print("key:$key\tvalue:\t$value");
    // });
  }

  @override
  instance() {
    // TODO: implement instance
    return Attachment();
  }

  @override
  Map<String, dynamic> toJson() {
    // TODO: implement toJson
    var map = <String, dynamic>{};
    map["FileId"] = FileId;
    map["FileName"] = FileName;
    map["FilePatch"] = FilePatch;
    map["StatusDescription"] = StatusDescription;
    return map;
  }

  ///打开文件
  void open(BuildContext context) {
    FileUtils.openFile(context, Url.getFileUrl(FilePatch));
  }

  ///文件分享
  void share(BuildContext context) {
    FileUtils.shareFile(context, Url.getFileUrl(FilePatch));
  }
}
